﻿using RuoVea.ExDto;
using RuoVea.ExEnum;
using RuoVea.ExSugar.Entity;
using RuoVea.OmiApi.Article.Entitys;
using System.ComponentModel.DataAnnotations;

namespace RuoVea.OmiApi.Article.Service.Dto;

/// <summary>
/// 文章
/// </summary>
public class ArticleParam : PageParam
{
    /// <summary>
    /// 用户Id
    /// </summary>
    public long UserId { get; set; }

    /// <summary>
    /// 标题
    /// </summary>
    public string Title { get; set; }

    /// <summary>
    /// 文章副标题
    /// </summary>
    public string Subtitle { get; set; }

    /// <summary>
    /// 文章摘要
    /// </summary>
    public string Summary { get; set; }

    /// <summary>
    /// 状态：0-草稿，1-已发布，2-已下架
    /// </summary>
    public int? Status { get; set; }

    /// <summary>
    /// 是否置顶
    /// </summary>
    public YesOrNot? IsTop { get; set; }

    /// <summary>
    /// 是否精选
    /// </summary>
    public YesOrNot? IsFeatured { get; set; }

    /// <summary>
    /// 是否允许评论：0-否，1-是
    /// </summary>
    public YesOrNot? IsCommentAllowed { get; set; }

    /// <summary>
    /// 标签列表 
    /// </summary>
    public List<long> TagIds { get; set; }

    /// <summary>
    /// 分类列表 
    /// </summary>
    public List<long> CategorieIds { get; set; }
    /// <summary>
    /// 分类状态-正常_0、停用_1 
    /// </summary>
    public YesOrNot? CategorieIsDisable { get; set; }
    /// <summary>
    /// 
    /// </summary>
    private int _currentPage;
    /// <summary>
    /// 
    /// </summary>
    public int CurrentPage
    {
        get { return _currentPage; }
        set
        {
            _currentPage = value;
            base.PageNo = value;
        }
    }
}

/// <summary>
/// 文章
/// </summary>
public class ArticleOutputDto : EntityBase
{
    /// <summary>
    /// 标题
    /// </summary> 
    public string Title { get; set; }

    /// <summary>
    /// 文章副标题
    /// </summary> 
    public string Subtitle { get; set; }

    /// <summary>
    /// 文章摘要
    /// </summary> 
    public string Summary { get; set; }

    /// <summary>
    /// 封面图片URL
    /// </summary> 
    public string CoverImage { get; set; }

    /// <summary>
    /// 状态：0-草稿，1-已发布，2-已下架
    /// </summary> 
    public int Status { get; set; }

    /// <summary>
    /// 排序
    /// </summary> 
    public int Sort { get; set; } = 10;

    /// <summary>
    /// 阅读量
    /// </summary> 
    public long ViewCount { get; set; } = 0;

    /// <summary>
    /// 点赞数
    /// </summary> 
    public int LikeCount { get; set; } = 0;

    /// <summary>
    /// 评论数
    /// </summary> 
    public long CommentCount { get; set; } = 0;

    /// <summary>
    /// 是否置顶
    /// </summary> 
    public YesOrNot IsTop { get; set; } = YesOrNot.N;

    /// <summary>
    /// 是否精选
    /// </summary> 
    public YesOrNot IsFeatured { get; set; } = YesOrNot.N;

    /// <summary>
    /// 是否允许评论：0-否，1-是
    /// </summary> 
    public YesOrNot IsCommentAllowed { get; set; } = YesOrNot.Y;

}

/// <summary>
/// 文章
/// </summary>
public class ArtArticleOutDto : EntityBase
{
    /// <summary>
    /// 标题
    /// </summary> 
    public string Title { get; set; }

    /// <summary>
    /// 文章副标题
    /// </summary> 
    public string Subtitle { get; set; }

    /// <summary>
    /// 文章摘要
    /// </summary> 
    public string Summary { get; set; }

    /// <summary>
    /// 封面图片URL
    /// </summary> 
    public string CoverImage { get; set; }

    /// <summary>
    /// 状态：0-草稿，1-已发布，2-已下架
    /// </summary> 
    public int Status { get; set; }

    /// <summary>
    /// 排序
    /// </summary> 
    public int Sort { get; set; } = 10;

    /// <summary>
    /// 阅读量
    /// </summary> 
    public long ViewCount { get; set; } = 0;

    /// <summary>
    /// 点赞数
    /// </summary> 
    public int LikeCount { get; set; } = 0;

    /// <summary>
    /// 评论数
    /// </summary> 
    public long CommentCount { get; set; } = 0;

    /// <summary>
    /// 是否置顶
    /// </summary> 
    public YesOrNot IsTop { get; set; } = YesOrNot.N;

    /// <summary>
    /// 是否精选
    /// </summary> 
    public YesOrNot IsFeatured { get; set; } = YesOrNot.N;

    /// <summary>
    /// 是否允许评论：0-否，1-是
    /// </summary> 
    public YesOrNot IsCommentAllowed { get; set; } = YesOrNot.Y;

    /// <summary>
    /// 文章内容
    /// </summary> 
    public string Content { get; set; }

    /// <summary>
    /// 导航属性 - SEO（一对一）
    /// </summary> 
    public ArtSeo Seo { get; set; }

    /// <summary>
    /// 导航属性 - 点赞列表（一对多）
    /// </summary> 
    public List<ArtLike> Likes { get; set; }

    /// <summary>
    /// 导航属性 - 收藏列表（一对多）
    /// </summary> 
    public List<ArtFavorite> Favorites { get; set; }

    /// <summary>
    /// 导航属性 - 评论列表（一对多）
    /// </summary> 
    public List<ArtComment> Comments { get; set; }

    /// <summary>
    /// 导航属性 - 标签列表（多对多）
    /// </summary>
    public List<ArtTag> Tags { get; set; }

    /// <summary>
    /// 导航属性 - 分类列表（多对多）
    /// </summary>
    public List<ArtCategory> Categories { get; set; }

    /// <summary>
    /// 标签列表 
    /// </summary>
    public List<long> TagIds => Tags?.Select(x => x.Id)?.ToList();

    /// <summary>
    /// 分类列表 
    /// </summary>
    public List<long> CategorieIds => Categories?.Select(x => x.Id)?.ToList();

    /// <summary>
    /// 
    /// </summary>
    public long? CategorieId => Categories?.Select(x => x.Id).FirstOrDefault();
}

/// <summary>
/// 文章
/// </summary>
public class ArtArticleOutPutDto : EntityBase
{
    /// <summary>
    /// 标题
    /// </summary> 
    public string Title { get; set; }

    /// <summary>
    /// 文章副标题
    /// </summary> 
    public string Subtitle { get; set; }

    /// <summary>
    /// 文章摘要
    /// </summary> 
    public string Summary { get; set; }

    /// <summary>
    /// 封面图片URL
    /// </summary> 
    public string CoverImage { get; set; }

    /// <summary>
    /// 状态：0-草稿，1-已发布，2-已下架
    /// </summary> 
    public int Status { get; set; }

    /// <summary>
    /// 排序
    /// </summary> 
    public int Sort { get; set; } = 10;

    /// <summary>
    /// 阅读量
    /// </summary> 
    public long ViewCount { get; set; } = 0;

    /// <summary>
    /// 点赞数
    /// </summary> 
    public int LikeCount { get; set; } = 0;

    /// <summary>
    /// 评论数
    /// </summary> 
    public long CommentCount { get; set; } = 0;

    /// <summary>
    /// 是否置顶
    /// </summary> 
    public YesOrNot IsTop { get; set; } = YesOrNot.N;

    /// <summary>
    /// 是否精选
    /// </summary> 
    public YesOrNot IsFeatured { get; set; } = YesOrNot.N;

    /// <summary>
    /// 是否允许评论：0-否，1-是
    /// </summary> 
    public YesOrNot IsCommentAllowed { get; set; } = YesOrNot.Y;
}

/// <summary>
/// 文章
/// </summary>
public class ArticleDto
{
    /// <summary>
    /// 主键Id
    /// </summary>
    public long Id { get; set; }
    /// <summary>
    /// 标题
    /// </summary>
    [Required]
    public string Title { get; set; }

    /// <summary>
    /// 文章副标题
    /// </summary>
    public string Subtitle { get; set; }

    /// <summary>
    /// 文章摘要
    /// </summary>
    public string Summary { get; set; }

    /// <summary>
    /// 封面图片URL
    /// </summary>
    public string CoverImage { get; set; }

    /// <summary>
    /// 状态：0-草稿，1-已发布，2-已下架
    /// </summary>
    public int Status { get; set; }

    /// <summary>
    /// 排序
    /// </summary>
    public int Sort { get; set; } = 10;

    /// <summary>
    /// 是否置顶
    /// </summary>

    public YesOrNot IsTop { get; set; } = YesOrNot.N;

    /// <summary>
    /// 是否精选
    /// </summary>
    public YesOrNot? IsFeatured { get; set; } = YesOrNot.N;

    /// <summary>
    /// 是否允许评论：0-否，1-是
    /// </summary>
    public YesOrNot? IsCommentAllowed { get; set; } = YesOrNot.Y;

    /// <summary>
    /// 文章内容
    /// </summary>
    [Required]
    public string Content { get; set; }

    /// <summary>
    /// 导航属性 - SEO（一对一）
    /// </summary>
    public SeoDto? Seo { get; set; }

    /// <summary>
    /// 导航属性 - 标签列表（多对多）
    /// </summary>
    public List<long>? Tags { get; set; }

    /// <summary>
    /// 导航属性 - 分类列表（多对多）
    /// </summary>
    public List<long>? Categories { get; set; }
}

/// <summary>
/// seo
/// </summary>
public class SeoDto
{
    /// <summary>
    /// SEO标题
    /// </summary>
    public string MetaTitle { get; set; }

    /// <summary>
    /// SEO关键词
    /// </summary>
    public string MetaKeywords { get; set; }

    /// <summary>
    /// SEO描述
    /// </summary>
    public string MetaDescription { get; set; }

    /// <summary>
    /// 规范URL
    /// </summary>
    public string CanonicalUrl { get; set; }

}
